package com.brainstore.patterns.state;

/**
 * Created by IntelliJ IDEA.
 * User: Дима
 * Date: 09.03.12
 * Time: 19:56
 * To change this template use File | Settings | File Templates.
 */

//Класс работы с tcp-соединениями.

public class TCPConnection {
    TCPState state;



    public TCPConnection() {
        state = TCPClosed.Instance();
    }

    public void ActiveOpen() {
        state.ActiveOpen(this);
    }

    public void PassiveOpen() {
        state.PassiveOpen(this);
    }

    public void Close() {
        state.Close(this);
    }

    public void Send() {
        state.Send(this);
    }

    public void Acknowledge() {
        state.Acknowledge(this);
    }

    public void Synchronize() {
        state.Synchronize(this);
    }

    public void ProcessOctet(TCPOctetStream octStream) {
/* Обработка двоичного потока
* ...
*/
    }

    void ChangeState(TCPState state) {
        this.state = state;
    }
}
